package
        com.chb.service.impl;

import com.chb.dao.RoleDao;
import com.chb.model.entity.Role;
import com.chb.model.vo.PageBean;
import com.chb.model.vo.Result;
import com.chb.service.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author：xIAO_ZHOU_TX
 * @date：Created in 2023/9/26 15:15
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    @Override
    public PageBean<Role> findAllRoleInfo(Integer currentPage, Integer pageSize) {
        //分页插件
        PageHelper.startPage(currentPage, pageSize);
        List<Role> roles = roleDao.selectAllRoleInfo();
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        return new PageBean<Role>(pageInfo.getTotal(), pageInfo.getList());
    }


    //    添加角色
    @Override
    public Integer insertRole(Role role) {
        Integer integer = roleDao.insertRole(role);
        return integer;
    }

    //删除角色
    @Override
    public Integer deleteRole(Role role) {
        Integer integer = roleDao.deleteRole(role);
        return integer;
    }

    //修改角色
    @Override
    public Integer updateRole(Role role) {
        Integer integer = roleDao.updateRole(role);
        return integer;
    }
    //查询所有的职位
    @Override
    public Result findRolename() {
        List<Role> roles = roleDao.selectAllRoleInfo();
        return new Result(200,"查询成功",roles);
    }


}